package main

import (
	"fmt"
	"sort"
)

func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
	var result float64
	var totalnum []int
	//合并切片,调整顺序
	totalnum = append(nums1, nums2...)
	sort.Ints(totalnum)

	//判断合并数组大小是奇数还是偶数，让他除以2，可以整除就是偶数，反之就是奇数
	size := len(totalnum)

	if size%2 == 1 {
		//奇数个数就取取中间的数
		result = float64(totalnum[size/2])
	} else {
		//偶数个就取中间两个数
		result = (float64(totalnum[size/2] + totalnum[(size/2)-1])) / 2

	}

	return result

}

func main() {

	nums1 := []int{}
	nums2 := []int{1}

	num := findMedianSortedArrays(nums1, nums2)
	fmt.Printf("%f", num)
}
